import os
import sys
from sqlalchemy import text

# 确保可以导入项目根目录模块
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from database.connection import engine

def check_site_table() -> None:
    """
    检查 MySQL 数据库中 site_info 表是否存在，并输出记录数
    """
    with engine.connect() as conn:
        tables = list(conn.execute(text("SHOW TABLES LIKE 'site_info'")))
        print("tables:", tables)
        if tables:
            count = conn.execute(text("SELECT COUNT(*) FROM site_info")).scalar()
            print("site_info_count:", count)
        else:
            print("site_info_count:", 0)

if __name__ == "__main__":
    check_site_table()
